package service.impl;

import entity.Book;
import entity.BookList;
import jdk.internal.dynalink.linker.LinkerServices;
import service.IOperation;

import java.util.List;

/**
 * 归还图书
 */
public class ReturnBookIOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("您现在进行的是“归还图书“的操作(*^▽^*)");
        System.out.println("请输入图书名称：");
        String bookName = scanner.next();
        List<Book> bookBorrowed = bookList.bookBorrowed;
        for (Book book : bookBorrowed) {
            if (book.getBookName().equals(bookName)) {
                bookBorrowed.remove(book);
                bookList.add(book);
                System.out.println("归还图书成功(*^▽^*)");
                return;
            }
        }
        System.out.println("归还图书失败请联系图书管理员！");
    }
}
